package com.example.myproject.expressionengine;

import com.googlecode.aviator.AviatorEvaluator;

import java.io.File;
import java.io.FileOutputStream;

/**
 * Created by Administrator on 2017/12/29.
 */
public class TestAviator {
    public static void main(String[] args) throws  Exception{
//        AviatorEvaluator.setTrace(true);
//        AviatorEvaluator.setTraceOutputStream(new FileOutputStream(new File("e:/aviator.log")));
            long start0 = System.currentTimeMillis();
            Object a = AviatorEvaluator.execute("false ||false || false || true");
            System.out.println("t2=="+(System.currentTimeMillis()-start0));

        long starta = System.currentTimeMillis();
        AviatorEvaluator.execute("false ||true || true || false");
        System.out.println("t22=="+(System.currentTimeMillis()-starta));

            Object t3 = AviatorEvaluator.execute("true && (false || false)");
            System.out.println("t3=="+t3);



        Long result = (Long) AviatorEvaluator.execute("1+2+3");
        System.out.println(result);

        //逻辑表达式
        long start = System.currentTimeMillis();
        Object t = AviatorEvaluator.execute("true&&true");
        System.out.println("cal cost time=="+(System.currentTimeMillis()-start)+",t="+t);
        //



        String tm ="w";
        Object t2 = AviatorEvaluator.execute("w=="+tm);
        System.out.println(t2);
    }
}
